const { contextBridge, ipcRenderer } = require('electron');

// const low = require('lowdb');
// const FileSync = require('lowdb/adapters/FileSync');

contextBridge.exposeInMainWorld('App', {
    allenfunc: (name) => {
        return "hello >>>###! " + name;
    },
    openDialog: (callback) => {
        ipcRenderer.on("asynchronous-reply", function(event, arg) {
            // 这里的arg是从主线程请求的数据
            document.getElementById('show-content').innerHTML = arg.fileName;
            callback(arg.datas);
        });

        // 这里的会传递回给主进程，这里的第一个参数需要对应着主进程里on注册事件的名字一致
        ipcRenderer.send("asynchronous-message", {
            title: '选择Excel文件',
            properties: ['openFile'],
            filters: [
                { name: 'excel', extensions: ['xlsx'] },
            ]
        });
    }
});